<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title></title>
<link href="css/index2.css" rel="stylesheet" />
</head>
<body>
<div class="cardLinkage">
  <div class="headTitle"> <img onclick="goback()" src="./img/leftArrow.jpg" />
    <p>关联合肥通</p>
    </div>
  <div class="conetnt">
    <dl class="chooseCon"><dt><img src="./img/choosebtn.png" /></dt> 
      <dd><h2>请选择要关联的卡片</h2></dd>
    </dl>
    <ul class="cardlist shadowList">
      <!--<li>
        <p> <span class="cardTitle">合肥通普通卡</span> <span class="cardNum">8089 9999 0889 9866</span> </p>
        <button type="button">关联</button>
      </li>
      <li>
        <p> <span class="cardTitle">合肥通学生卡</span> <span class="cardNum">8089 9999 0889 9866</span> </p>
        <button type="button">关联</button>
      </li>
      <li>
        <p> <span class="cardTitle">合肥通普通卡</span> <span class="cardNum">8089 9999 0889 9866</span> </p>
        <button type="button" class="btnLinked">已关联</button>
      </li>-->
    </ul>
     <p><a>没有想要的卡片，换其他方式关联</a></p>
    <div class="linkageStyle" style="display: none;" >
      <div class="shadow-con">
        <h5> 请选择关联方式 <i class="close"></i> </h5>
        <ul class="stylelist">
          <li> <i><img class="linkicon" src="./img/linkstyle01.png" /></i>
            <p class="cardContent"> <span class="cardTitle">1.NFC验证关联</span> <span class="cardNum">NFC手机读取卡号后直接关联</span> <img class="rightArrow" src="./img/rightArrow.jpg" /> </p>
          </li>
          <li> <i><img class="linkicon" src="./img/linkstyle02.png" /></i>
            <p class="cardContent"> <span class="cardTitle">2.身份证查询关联</span> <span class="cardNum">身份证查询关联</span> <img class="rightArrow" src="./img/rightArrow.jpg" /> </p>
          </li>
          <li href="cardList.html"> <i><img class="linkicon" src="./img/linkstyle03.png" /></i>
            <p class="cardContent"> <span class="cardTitle">3.交易记录查询关联</span> <span class="cardNum">通过本账号交易过的卡</span> <img class="rightArrow" src="./img/rightArrow.jpg" /> </p>
          </li>
        </ul>
      </div>
    </div>
  </div>
</div>
<script src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/oldPublic.js" ></script>
<script src="js/code.js"></script>
<script src="js/security.js"></script>
<script>
	var login_name = sessionStorage.getItem('login_name');
	var telphone = sessionStorage.getItem('telphone');
	var orgcode = sessionStorage.getItem('orgcode');
	var idno = sessionStorage.getItem('idno');
	var idtype = sessionStorage.getItem('idtype');
	var nameIndex = sessionStorage.getItem('name');
	
	var locationUrl = window.location.href;
	var bindType = locationUrl.split('?')[1].split('=')[1];
	var bus_type;
//	var idno = locationUrl.split('?')[1].split('&')[0];
//	var idtype = locationUrl.split('?')[1].split('&')[1];
//	var name =  locationUrl.split('?')[1].split('&')[2];
//	var bindType = locationUrl.split('?')[1].split('&')[3];
//	idno = idno.substring(5,idno.length);
//	idtype = idtype.split('=')[1];
//	name = name.substring(5,idno.length);
//	bindType = bindType.split('=')[1];
	if(bindType=='id'){
		bus_type = '2';
	}else if(bindType=='recode'){
		bus_type = '3';
	}else if(bindType=='nfc'){
		bus_type = '1';
	}
		$.ajax({
				type:"post",
				url:sessionStorage.getItem('ipconfig'),
				data:JSON.stringify({data:encryptByDESModeEBC(JSON.stringify({"tag": "9101", 'login_name': login_name, 'telphone': telphone, 'bus_type': bus_type, 'name': '0084', 'idtype': '01','idno':'0084','orgcode':orgcode}))}),
				contentType: "application/json;charset=utf-8",
				success:function(data){
					console.log(data);
					if(data.result=='00'){
						var str = '';
						var card_info = data.card_info;
						for(var i=0;i<data.card_info.length;i++){
							str+= '<li>'+
							        '<p> <span class="cardTitle">'+changeType(data.card_info[i].systemid)+'</span> <span class="cardNum">'+data.card_info[i].cardno+'</span> </p>'+
							        '<button type="button" datacardno='+data.card_info[i].cardno+' datasystemid='+data.card_info[i].systemid+' onclick="relation(this)">关联</button>'+
							     '</li>'
						}
						$('.cardlist').html(str);
					}else{
						showWarn(data.description);
					}
				}
			});
			
			function relation(a){
				var systemid = $(a).attr('datasystemid');
				var datacardno = $(a).attr('datacardno');
				var that = a;
				$.ajax({
				type:"post",
				url:sessionStorage.getItem('ipconfig'),
				data:JSON.stringify({data:encryptByDESModeEBC(JSON.stringify({"tag": "9100", 'login_name': '15807102625FF', 'telphone': '15088888888', 'bus_type': '2', 'acct_no': datacardno, 'acct_type': systemid,'name': '0084', 'idtype': '01','idno':'0084','orgcode':orgcode}))}),
				contentType: "application/json;charset=utf-8",
				success:function(data){
					console.log(data);
					if(data.result=='00'){
							showWarn('关联成功！');
							$(that).addClass('btnLinked');
							$(that).attr('disabled','disabled');
							$(that).html('已关联');
					}else{
						showWarn(data.description);
					}
				}
			})
			}
			function changeType(a){
				var nameText = ''
				if(a=='001'){
					nameText = '住建部'
				}else if(a=='002'){
					nameText = 'Pboc'
				}else if(a=='003'){
					nameText = '交通部'
				}else if(a=='004'){
					nameText = '62BBIN'
				}else if(a=='005'){
					nameText = '虚拟电子卡'
				}else if(a=='006'){
					nameText = '账户系统'
				}
				return nameText
			}
</script>
</body>
</html>
